package com.liujit.validator.constraints.validate;

import org.springframework.util.StringUtils;

import java.util.regex.Pattern;

/**
 * @author: liujun
 * @date: 2021/6/22 1:37 下午
 * @description: 共通验证方法
 */
public class BaseValid {

    /**
     * 验证
     *
     * @param pattern
     * @param s
     * @return
     */
    public Boolean valid(Pattern pattern, String s) {
        if (StringUtils.hasLength(s)) {
            return pattern.matcher(s).matches();
        } else {
            return false;
        }
    }
}
